package test.rftennis.dao;


import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.rftennis.dao.CustomerDao;
import com.rftennis.dao.SqlSessionUtil;
import com.rftennis.entity.CustomerEntity;

public class testCustomerDao {
	SqlSession session;
	CustomerDao dao;
	@BeforeEach
	void beforeTest() {
		 session=SqlSessionUtil.getSession();
		 dao=session.getMapper(CustomerDao.class);
	}
@AfterEach
	
	void afterTest() {
		session.commit();
		session.close();
	}
	@Test
	public void testInsert() throws Exception {
		
		Assertions.assertNotNull(dao);
		CustomerEntity e=new CustomerEntity();
		e.setId("5");
		e.setName("朱凯");
		e.setAccount("789456");
		e.setPassword("456");
		e.setAddress("重庆花卉园");
		e.setPhoneNumber("12365478945");
		e.setMail("321458641@qq.com");
		e.setCreateTime(LocalDateTime.now());
		
		dao.insert(e);
		
		
		
	}
	@Test
	public void testdelete() throws Exception {
		
		Assertions.assertNotNull(dao);
		CustomerEntity e=new CustomerEntity();

		dao.delete("4");
		
		
		
	}
	@Test
	public void testupdate() throws Exception {
		
		Assertions.assertNotNull(dao);
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("name", "德约");
		

		dao.update("4", map);;
		
		
		
	}
	@Test
	public void testselect() throws Exception {
		
		
		CustomerEntity e=new CustomerEntity();
		Assertions.assertNotNull(dao);
	     e=dao.select("account", "151");
		
		
		
	}
}
